#include <iostream>
#include <string>
#include <cmath>

bool isPrime(int n) {
    if (n <= 1) {
        return false;
    }
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    std::string num1, num2, num3;
    std::cin >> num1 >> num2 >> num3;

    std::string numberStr = num1 + num2 + num3;
    if (numberStr.length() != 3) {
        std::cout << "Wrong input" << std::endl;
        return 0;
    }

    int number = std::stoi(numberStr);
    while (!isPrime(number)) {
        number++;
    }

    std::cout << number << std::endl;

    return 0;
}